From 5450603225779045e1dc04e8d5874d930a18a2b3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 9 Jul 2007 20:24:26 +0000 Subject: [PATCH] Don't ignore the passed-in len parameter. (#430049, Yevgen Muntyan) 2007-07-09 Matthias Clasen * gtk/gtkselection.c (normalize_to_crlf): Don't ignore the passed-in len parameter. (#430049, Yevgen Muntyan) svn path=/trunk/; revision=18423 --- ChangeLog | 5 +++++ gtk/gtkselection.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index e875da4556..b257b2938b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-07-09 Matthias Clasen + + * gtk/gtkselection.c (normalize_to_crlf): Don't ignore + the passed-in len parameter. (#430049, Yevgen Muntyan) + 2007-07-09 Matthias Clasen * gtk/gtkframe.c (gtk_frame_size_allocate): Improve the diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index b76090be20..16eb1c802d 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -1197,8 +1197,9 @@ normalize_to_crlf (const gchar *str, { GString *result = g_string_sized_new (len); const gchar *p = str; + const gchar *end = str + len; - while (1) + while (p < end) { if (*p == '\n') g_string_append_c (result, '\r'); @@ -1207,13 +1208,12 @@ normalize_to_crlf (const gchar *str, { g_string_append_c (result, *p); p++; - if (*p != '\n') + if (p == end || *p != '\n') g_string_append_c (result, '\n'); + if (p == end) + break; } - if (*p == '\0') - break; - g_string_append_c (result, *p); p++; } -- 2.30.2